local huiguiziran = fk.CreateSkill{
    name = "ym2__huiguiziran",
}
Fk:loadTranslationTable{
    ["ym2__huiguiziran"] = "回归自然",
    [":ym2__huiguiziran"] = "你使用手牌造成伤害时，若你本回合使用牌数大于目标体力值，你可以改为杀死对方。",
    ["#ym2__huiguiziran-invoke"] = "回归自然：你可以将对 %dest 造成的伤害改为杀死对方",

    ["$ym2__huiguiziran1"] = "耶耶",
    ["$ym2__huiguiziran2"] = "就酱啦~",
    ["$ym2__huiguiziran3"] = "拜拜",
}
huiguiziran:addEffect(fk.DamageCaused,{
    anim_type = "offensive",
    can_trigger = function (self, event, target, player, data)
        if player:hasSkill(huiguiziran.name) and player == target and data then
            local room = player.room
            local y = 0
            y = y + #room.logic:getEventsByRule(GameEvent.UseCard, 999, function (e)
                return e.data.from == player
            end, nil, Player.HistoryTurn)
            local use_hand = false
            room.logic:getEventsByRule(GameEvent.UseCard, 999, function (e)
                if e.data.from == player and e.data.card.id == data.card.id then
                    local cardlist = Card:getIdList(data.card)
                    local use_event = e
                    e:searchEvents(GameEvent.MoveCards, 1, function(el)
                        if el.parent and el.parent.id == use_event.id then
                            local subcheck = table.simpleClone(cardlist)
                            for _, move in ipairs(el.data) do
                                if move.moveReason == fk.ReasonUse then
                                    if move.from and move.from == player then
                                        for _, info in ipairs(move.moveInfo) do
                                            if table.removeOne(subcheck, info.cardId) and info.fromArea == Card.PlayerHand then
                                                use_hand = true
                                                return true
                                            end
                                        end
                                    end
                                end
                            end
                        end
                    end)
                end
            end, nil, Player.HistoryTurn)
            return use_hand and y > data.to.hp
        end
    end,
    on_cost = function (self, event, target, player, data)
        if player.room:askToSkillInvoke(player,{
            skill_name = huiguiziran.name,
            prompt = "#ym2__huiguiziran-invoke::"..data.to.id
        }) then
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        data:preventDamage()
        room:killPlayer{
            who = data.to,
            killer = player,
            damage = data.damageEvent
        }
    end,
})
huiguiziran:addEffect(fk.TurnStart,{
    global = true,
    can_refresh = function (self, event, target, player, data)
        return target == player and player.general == "ym2__latika"
    end,
    on_refresh = function (self, event, target, player, data)
        local n = table.random({1,2})
        player.room:broadcastPlaySound("./packages/ym_Al/audio/show/ym2__latika-turn"..n)
        local str = {"咱的手臂被称为万绿，是这样来着？","人家都来了，赢定了啦"}
        player:chat(str[n])
    end,
})
huiguiziran:addEffect(fk.Damage,{
    global = true,
    can_refresh = function (self, event, target, player, data)
        return target == player and player.general == "ym2__latika"
    end,
    on_refresh = function (self, event, target, player, data)
        local n = table.random({1,2,3})
        player.room:broadcastPlaySound("./packages/ym_Al/audio/show/ym2__latika-turn"..n)
    end,
})
huiguiziran:addEffect(fk.Dying,{
    global = true,
    can_refresh = function (self, event, target, player, data)
        return target == player and player.general == "ym2__latika"
    end,
    on_refresh = function (self, event, target, player, data)
        local n = table.random({1,2})
        player.room:broadcastPlaySound("./packages/ym_Al/audio/show/ym2__latika-dying"..n)
        local str = {"哎呀搞砸了","糟糕"}
        player:chat(str[n])
    end,
})

return huiguiziran